<template>
  <div>
     <h1>我是兄弟二</h1>
     <button @click="sendbro">兄弟组件传值</button>
      <grand-son></grand-son>
  </div>
</template>

<script >
import grandSon from './grandSon.vue'
import {ref,getCurrentInstance } from 'vue'
import $mitt from '../../utils/mitt.js'
export default {
  components:{grandSon},
  setup(props){
    let {appContext}=getCurrentInstance();
      console.log(appContext)
      let mybroname=ref("我是关羽")
      let mynewname=ref("我是张飞")

      let sendbro=()=>{
          // 全局挂载的插件传
        appContext.config.globalProperties.$mitt.emit("sendguan",mybroname.value)

        $mitt.emit("sendzhang",mynewname.value)
      }
    return {
      sendbro
    }
  }
}
</script>
